package com.ruoyi.web.controller.util;

public class DateUtil {

    private static final long SECOND = 1000;
    private static final long MINUTE = 1000 * 60;
    private static final long HOUR = 1000 * 60 * 60;
    private static final long DAY = 1000 * 60 * 60 * 24;

    public static long getDiff(Long time1,Long time2){
        long diff = 0;
        if (time1 > time2){
            diff = time1 - time2;
        }else {
            diff = time2 - time1;
        }
        return diff;
    }

    public static String formateDate(Long time){
        String result = "";
        long day = time/DAY;
        long hour = time%DAY/HOUR;
        long minute = time%DAY%HOUR/MINUTE;
        if (day > 0)
            result = day + "天";
        else if (hour > 0)
            result += hour + "小时";
        else if (minute > 0)
            result += minute + "分钟";
        return result;
    }

    public static String formateDate(int minute){
        if (minute < 60)
            return minute + "分钟";
        if (minute > 1440)
            return minute/1440 + "天";
        return minute/60 + "小时";
    }
}
